<tr>
  <td data-label="<%= t("models.participatory_process.fields.title", scope: "decidim.admin") %>">
    <% if process.promoted? %>
      <%= icon_with_tooltip "star-s-fill", t("models.assembly.fields.promoted", scope: "decidim.admin") %>
    <% end %>
    <% if allowed_to? :update, :process, process: process %>
      <%= link_to translated_attribute(process.title), edit_participatory_process_path(process) %><br>
    <% elsif allowed_to? :read, :component, process: process %>
      <%= link_to translated_attribute(process.title), components_path(process) %><br>
    <% else %>
      <%= translated_attribute(process.title) %>
    <% end %>
  </td>
  <td class="table-list__date" data-label="<%= t("models.participatory_process.fields.created_at", scope: "decidim.admin") %>">
    <%= l process.created_at, format: :short %>
  </td>
  <td class="table-list__state" data-label="<%= t("models.participatory_process.fields.private", scope: "decidim.admin") %>">
    <% if process.private_space? %>
      <span><%= t("participatory_processes.index.private", scope: "decidim.admin") %></span>
    <% else %>
      <span><%= t("participatory_processes.index.public", scope: "decidim.admin") %></span>
    <% end %>
  </td>
  <td class="table-list__state" data-label="<%= t("models.participatory_process.fields.published", scope: "decidim.admin") %>">
    <% if process.published? %>
      <span class="label success !text-sm"><%= t("participatory_processes.index.published", scope: "decidim.admin") %></span>
    <% else %>
      <span class="label alert !text-sm"><%= t("participatory_processes.index.unpublished", scope: "decidim.admin") %></span>
    <% end %>
  </td>
  <td class="table-list__actions" data-label="<%= t("models.participatory_process.fields.actions", scope: "decidim.admin") %>">
    <button type="button" data-controller="dropdown" data-target="actions-process-<%= process.id %>" aria-label="<%= t("decidim.admin.actions.actions_label", resource: translated_attribute(process.title)) %>">
      <%= icon "more-fill", class: "text-secondary" %>
    </button>

    <div class="inline-block relative">
      <ul id="actions-process-<%= process.id %>" class="dropdown dropdown__action" aria-hidden="true">
        <% if view == :deleted %>

          <% if allowed_to? :restore, :process, trashable_deleted_resource: process %>
            <li class="dropdown__item">
              <%= link_to restore_participatory_process_path(process), class: "dropdown__button", method: :patch do %>
                <%= icon "refresh-line" %>
                <%= t("actions.restore", scope: "decidim.admin") %>
              <% end %>
            </li>
          <% end %>

        <% else %>

          <% if allowed_to? :update, :process, process: process %>
            <li class="dropdown__item">
              <%= link_to edit_participatory_process_path(process), class: "dropdown__button" do %>
                <%= icon "pencil-line" %>
                <%= t("actions.edit", scope: "decidim.admin") %>
              <% end %>
            </li>

            <hr>
          <% end %>

          <% if allowed_to? :create, :process, process: process %>
            <li class="dropdown__item">
              <%= link_to new_participatory_process_duplicate_path(process), class: "dropdown__button" do %>
                <%= icon "file-copy-line" %>
                <%= t("actions.duplicate", scope: "decidim.admin") %>
              <% end %>
            </li>
          <% end %>

          <% if allowed_to? :create, :process, process: process %>
            <li class="dropdown__item">
              <%= link_to participatory_process_export_path(process), class: "dropdown__button", method: :post do %>
                <%= icon "download-line" %>
                <%= t("actions.export", scope: "decidim.admin") %>
              <% end %>
            </li>
          <% end %>

          <hr>

          <% if allowed_to? :preview, :process, process: process %>
            <li class="dropdown__item">
              <%= link_to decidim_participatory_processes.participatory_process_path(process, locale: current_locale), class: "dropdown__button", target: "_blank", data: { "external-link": false } do %>
                <%= icon "eye-line" %>
                <%= t("actions.preview", scope: "decidim.admin") %>
              <% end %>
            </li>
          <% end %>

          <% if allowed_to? :read, :share_token, current_participatory_space: process %>
            <li class="dropdown__item">
              <%= link_to decidim_admin_participatory_processes.participatory_process_share_tokens_path(process), class: "dropdown__button" do %>
                <%= icon "share-line" %>
                <%= t("actions.share_tokens", scope: "decidim.admin") %>
              <% end %>
            </li>
          <% end %>

          <% if allowed_to? :publish, :process, process: process %>
           <li class="dropdown__item">
              <% if process.published? %>
                <%= link_to participatory_process_publish_path(process), method: :delete, class: "dropdown__button" do %>
                  <%= icon "close-circle-line" %>
                  <%= t("actions.unpublish", scope: "decidim.admin") %>
                <% end %>
              <% else %>
                <%= link_to participatory_process_publish_path(process), method: :post, class: "dropdown__button" do %>
                  <%= icon "check-line" %>
                  <%= t("actions.publish", scope: "decidim.admin") %>
                <% end %>
              <% end %>
            </li>
          <% end %>

          <hr>

          <% if allowed_to? :read, :moderation, process: process %>
            <li class="dropdown__item">
              <%= link_to moderations_path(process), class: "dropdown__button" do %>
                <%= icon "flag-line" %>
                <%= t("actions.moderate", scope: "decidim.admin") %>
              <% end %>
            </li>

            <hr>
          <% end %>

          <% if allowed_to? :soft_delete, :process, trashable_deleted_resource: process %>
            <% if process.published? %>
              <li class="dropdown__item">
                <div class="dropdown__button-disabled">
                  <%= with_tooltip t("tooltips.deleted_processes_info", scope: "decidim.admin") do %>
                    <%= icon "delete-bin-line", class: "text-gray" %>
                    <span>
                      <%= t("actions.soft_delete", scope: "decidim.admin") %>
                    </span>
                  <% end %>
                </div>
              </li>
            <% else %>
              <li class="dropdown__item">
                <%= link_to soft_delete_participatory_process_path(process), class: "dropdown__button", method: :patch, data: { confirm: t("actions.confirm_delete_process", scope: "decidim.admin") } do %>
                  <%= icon "delete-bin-line" %>
                  <%= t("actions.soft_delete", scope: "decidim.admin") %>
                <% end %>
              </li>
            <% end %>
          <% end %>

        <% end %>
      </ul>
    </div>
  </td>
</tr>
